import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author chen.haogang
 *
 */
public class MinScalarProduct {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader("".getClass().getResourceAsStream("/A-small-practice.in")));
			String testCaseNumber = br.readLine();
			System.out.println(testCaseNumber);
			for(int i = 0; i < Integer.valueOf(testCaseNumber); i++) {
				int product = 0;
				String intNumber = br.readLine();
				List<Integer> vector1 = new ArrayList<Integer>();
				List<Integer> vector2 = new ArrayList<Integer>();
				String[] numbers = br.readLine().split(" ");
				for(int j = 0; j < Integer.valueOf(intNumber); j++) {
					vector1.add(Integer.valueOf(numbers[j]));
				}
				numbers = br.readLine().split(" ");
				for(int j = 0; j < Integer.valueOf(intNumber); j++) {
					vector2.add(Integer.valueOf(numbers[j]));
				}
				Collections.sort(vector1);
				for(int j = 0; j < Integer.valueOf(intNumber); j++) {
					if(vector1.get(j) < 0) {
						int maxPositive = getMaxPositive(vector2);
						if (maxPositive > 0) {
							product += vector1.get(j) * maxPositive;
							vector2.remove(new Integer(maxPositive));
						} else {
							product += vector1.get(j) * getMaxNegative(vector2);
							vector2.remove(new Integer(getMaxNegative(vector2)));
						}
					} else {
						int maxPositive = getMaxPositive(vector2);
						if(maxPositive > 0) {
							product += vector1.get(j) * maxPositive;
							vector2.remove(new Integer(maxPositive));
						} else {
							product += vector1.get(j) * getMaxNegative(vector2);
							vector2.remove(new Integer(getMaxNegative(vector2)));
						}
					}
				}
				System.out.println("Case #" + (i + 1) + ": " + product);
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static int getMaxNegative(List<Integer> vector2) {
		int max = 0;
		for(int i = 0; i < vector2.size(); i++) {
			if(max >= 0 && vector2.get(i) < 0) {
				max = vector2.get(i);
			}
			if(vector2.get(i) < 0 && vector2.get(i) > max) {
				max = vector2.get(i);
			}
		}
		return max;
	}

	private static int getMinPositive(List<Integer> vector2) {
		int min = -1;
		for(int i = 0; i < vector2.size(); i++) {
			if(min < 0 && vector2.get(i) > 0) {
				min = vector2.get(i);
			}
			if(vector2.get(i) > 0 && vector2.get(i) < min) {
				min = vector2.get(i);
			}
		}
		return min;
	}

	private static int getMaxPositive(List<Integer> vector2) {
		int max = 0;
		for(int i = 0; i < vector2.size(); i++) {
			if(vector2.get(i) > max) {
				max = vector2.get(i);
			}
		}
		return max;
	}

	private static int getMinNegative(List<Integer> vector1) {
		int min = 0;
		for(int i = 0; i < vector1.size(); i++) {
			if(vector1.get(i) < min) {
				min = vector1.get(i);
			}
		}
		return min;
	}

}
